package com.yiheima.exam;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor// @Data注解会生成get/set方法，@AllArgsConstructor注解会生成全参数构造方法，@NoArgsConstructor注解会生成无参构造方法
@NoArgsConstructor
public class Card {
    private String cardId;
    private String name;
    private String phone;
    private double money;
    //存入金额
    public void deposit(double amount){
        this.money += amount;
    }
    //取出金额
    public void consume(double amount) {
        if (this.money >= amount) {
            this.money -= amount;
        } else {
            System.out.println("余额不足！");
        }
    }
}
